package structure.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dali
 * @date 2021-07-19 16:49
 * @Description
 */

public class DeptComposite implements Component{
    private String name;
    private List<Component> organizationComponents = new ArrayList<>();

    public DeptComposite(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void add(Component o) {
        organizationComponents.add(o);
    }

    @Override
    public Component getChild() {
        for (Component temp : organizationComponents) {
            if (temp != null) {
                System.out.println(name+"下有"+temp.getName());
                temp.getChild();
            }
        }
        return null;
    }
}
